import axios from "axios" //网络请求
import {showMessage} from "@/utils" //提示框

const ins = axios.create() //创建axios实例
const res = ins.interceptors.response.use(function(res){ //拦截响应，优先执行实参函数
    // console.log(res.data)
    if(res.data.code === 0){ //正常响应
        return res.data.data
    }else{ //非正常响应
        showMessage(res.data.msg, "error", 2000, document.getElementsByClassName("home-container")[0]) //错误提示框
        return undefined;
    }
})

export default ins